


module('userop',package.seeall)
local m_logarr = {};  



function userop(title)  
  if #m_logarr >= 100 then 
    table.remove(m_logarr,1);
  end
  table.insert(m_logarr,title);
end 


local platform=cc.Application:getInstance():getTargetPlatform();
local m_haveSend=false


-- for CCLuaEngine traceback
function sendLog(msg) 
	 if m_haveSend then 
		return
	end  
    local trace=debug.traceback() 
	msg = tostring(msg)  
	--发送错误报告并弹出错误框   
	local device= require "cocos.framework.device"  
	m_haveSend= true 
	require 'checkversion'
	local size=cc.Director:getInstance():getWinSize();
	local versioninfo = checkversion.gd_version
	local version = (versioninfo.versionstr and (versioninfo.versionstr .. '-v:' .. versioninfo.version .. '-b:' .. versioninfo.build .. '-des:' .. versioninfo.des))  or '版本未获取';
	local logdata = 
	'版本详情:\n' .. '模式=' .. gd_testmode .. ',分辨率=' .. size.width .. 'X' .. size.height ..  ',系统=' .. device.platform .. ',渠道=' .. gd_channel  .. ',版本信息=' .. version .. '\n' .. 
	'LUA错误:\n' .. msg .. '\n' .. 
	'调用栈信息:\n' .. trace .. '\n' .. 
	'玩家最近' .. #m_logarr .. '个操作:\n';
	for i = 1,#m_logarr do 
		logdata = logdata .. '->' .. m_logarr[i];
	end  	
	print("lua出错了") 
	print(logdata)
	--发送错误报告并弹出错误框
	local phonearr={'android','ios'};
	c_showMsgBox('系统提示','网络错误请重启');
	for key,value in pairs(phonearr) do 
		if device.platform == value then
			c_sendLog('http://218.18.232.38/logs/uplog.php','data=系统是' .. device.platform .. '错误详情:\n' .. logdata);    
		end
	end   
end
  






function showError(msg) 
	local errStr = "\n--------------------------[function showError ERROR] >>\n"..msg.."\n--------------------------\n\n"
	print(errStr)
	-- c_showMsgBox('系统提示','网络错误请重启');
end

